<?php

use yii\helpers\Html;
use yii\grid\GridView;
use mdm\admin\components\Helper;
use common\models\kaoguobao\Order;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '订单详情';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="account-wechat-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            'id',
            'order_num',
            [
                'attribute' => 'order_status',
                'value' => function($model) {
                    if (isset($model->order_status)) {
                        return Order::$orderStatus[$model->order_status];
                    }else{
                        return '';
                    }
                },
            ],
            'user_id',
            'benefit_id',
            [
                'attribute' => 'amount',
                'value' => function($model) {
                    return number_format($model->amount/100,2);
                },
            ],
            'key',
            [
                'attribute' => 'type',
                'value' => function($model) {
                    if (isset($model->type)) {
                        return Order::$typeName[$model->type];
                    }else{
                        return '';
                    }
                },
            ],
            'remarks',
            'start_time:date',
            'end_time:date',
            'created_at:date',
            [
                'class' => 'yii\grid\ActionColumn',
                'template' => Helper::filterActionColumn(['view', 'order_status' ,'order-handle']),
                'buttons' => [
                    'order-handle' => function($url, $model){
                        if (isset($model->order_status) && $model->order_status == Order::ORDER_STATUS_UP_PROOF) {
                            return Html::a('查看凭证', $url, ['title'=> '查看凭证'] );
                        }elseif(isset($model->order_status) && $model->order_status == Order::ORDER_STATUS_HANDLED){
                            return Html::a('红包赔付', $url, ['title'=> '赔付'] );
                        }elseif(isset($model->order_status) && $model->order_status == Order::ORDER_STATUS_PAYMENT) {
                            return Html::a('业务回调', $url, ['title' => '业务回调']);
                        }else{
                            return '';
                        }
                    }
                ]
            ],
        ],
    ]); ?>

</div>
